
#include <stdint.h>

#include "Timer.h"

static Timer_T bspClockTimer;
static uint32_t clockNow = 0;

static void BSP_Clock_Dummy(uint32_t now){

}

static void(*bspClockTickCB)(uint32_t) = BSP_Clock_Dummy;

static void BSP_Clock_TickCB(void){
	clockNow++;
	bspClockTickCB(clockNow);
}

void BSP_Clock_Init(void){
	Timer_Setup(&bspClockTimer, 100, 1, 0, BSP_Clock_TickCB);
	Timer_Start(&bspClockTimer);
	
}

void BSP_Clock_Set(uint32_t val){
	clockNow = val;
}

uint32_t BSP_Clock_Now(void){
	return clockNow;
}

void BSP_Clock_RegisterTick(void(*tick)(uint32_t)){
	bspClockTickCB = tick;
}



